/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-11-05
 * Time: 13:52
 */
public class Test2 {
    public int firstUniqChar(String s) {
        int[] count = new int[26];

        for (int i = 0; i < s.length(); i++) {
            int a = s.charAt(i) - 97;
            count[a] = count[a] + 1;
        }

        for (int i = 0; i < s.length(); i++) {
            int a = s.charAt(i) - 97;
            if(count[a] == 1) {
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Test2 test2 = new Test2();
        System.out.println(test2.firstUniqChar("loveleetcode"));
    }
}
